package com.cskaoyan.dbutils;

import com.cskaoyan.connectionpool.opensource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * 创建日期: 2022/08/29 09:56
 *
 * @author ciggar
 *
 * QueryRunner
 *
 * 执行Update方法、传入Connection对象
 */
public class Demo2 {

    public static void main(String[] args) throws SQLException {


        // 无参构造方法
        QueryRunner queryRunner = new QueryRunner();

        // 获取Connection
        Connection connection = DruidUtils.getConnection();

        int affectedRows = queryRunner.update(connection,"update user set username = ?,nickname=? where id = ?",
                "王英","矮脚虎","1004");


        System.out.println("affectedRows:" + affectedRows);

        connection.close();



    }


}
